package com.minhua.jijiehao2.mainframe.mine.updatenicknameactivity.impl

import android.text.TextUtils
import com.minhua.jijiehao2.base.BaseMvpPresenter
import com.minhua.jijiehao2.bean.BaseBean
import com.minhua.jijiehao2.constants.DefineKey
import com.minhua.jijiehao2.http.CallBack
import com.minhua.jijiehao2.http.ParamsMap
import com.minhua.jijiehao2.mainframe.mine.updatenicknameactivity.imp.IUpdateNickNamePresenter
import com.minhua.jijiehao2.mainframe.mine.updatenicknameactivity.imp.IUpdateNickNameView
import com.minhua.jijiehao2.utils.T

class UpdateNickNamePresenter : BaseMvpPresenter<IUpdateNickNameView>(), IUpdateNickNamePresenter {

    private val mUpdateNickNameModel = UpdateNickNameModel()

    override fun updateName() {
        val nickName = v?.getNickName() ?: ""
        if (TextUtils.isEmpty(nickName)) {
            T.showShort("昵称不能为空")
            return
        }
        val map = ParamsMap()
        map.put(DefineKey.USER_NICK_NAME, nickName)
        mUpdateNickNameModel.updateName(map, object : CallBack<Any>() {
            override fun onSuccess(t: BaseBean<Any>) {
                v?.onUpdateNameSuccess()
            }
        })

    }
}